package com.firebugsoft.calc.web.log4j.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value={"/calc"})
public class CalcController {
    private Logger logger = LoggerFactory.getLogger("console");

    @RequestMapping(value = {"/add"})
    public double add(double a, double b) {
        double c = a + b;
        logger.info("{} + {} = {}", a, b, c);
        return c;
    }

    @RequestMapping(value = {"/sub"})
    public double sub(double a, double b) {
        double c = a - b;
        logger.info("{} - {} = {}", a, b, c);
        return c;
    }

    @RequestMapping(value = {"/mul"})
    public double mul(double a, double b) {
        double c = a * b;
        logger.info("{} * {} = {}", a, b, c);
        return c;
    }

    @RequestMapping(value = {"/div"})
    public double div(double a, double b) {
        double c = a / b;
        logger.info("{} / {} = {}", a, b, c);
        return c;
    }
}
